package com.triones.ljr.controller.api;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import com.triones.ljr.entity.bo.DeclareAuditBO;
import com.triones.ljr.entity.dto.DeclareAuditDO;
import com.triones.ljr.entity.vo.CustomDeclareAuditVO;
import com.triones.ljr.service.DeclareAuditService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;

/**
 * api - 申报审核
 *
 * @Author: triones
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/api/declareAudit")
public class ApiDeclareAuditController extends BaseController {

    private final DeclareAuditService declareAuditService;

    /**
     * 一键申报
     * @param bo
     * @return
     */
    @PostMapping("/add")
    public R<Void> add(@Validated @RequestBody DeclareAuditBO bo) {
        return toAjax(declareAuditService.add(bo));
    }

    /**
     * 我的申报记录（分页）
     * @param keyword
     * @param status
     * @return
     */
    @GetMapping("/myList")
    public TableDataInfo<CustomDeclareAuditVO> apiDeclarePageList(String keyword,String status, PageQuery pageQuery) {
        return declareAuditService.apiDeclarePageList(keyword,status, pageQuery);
    }

    /**
     * 申报详情
     * @param id
     * @return
     */
    @GetMapping("/detail/{id}")
    public R<CustomDeclareAuditVO> declareDetail(@NotNull(message = "申报记录id不能为空") @PathVariable Long id) {
        return R.ok(declareAuditService.declareDetail(id));
    }

    /**
     * 修改申报信息
     * @param bo
     * @return
     */
    @PostMapping("/edit")
    public R<Void> edit(@Validated @RequestBody DeclareAuditBO bo) {
        return toAjax(declareAuditService.edit(bo));
    }
}
